<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2020/8/4
  Time: 10:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>入党申请审核人员信息表</title>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8 ? MYOA_CHARSET : htmlspecialchars($HTML_PAGE_CHARSET))?>" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/eleTree.css">
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/layui/layui/layui.js"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/lib/layui/layui/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/attachment/attachView.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .locality-p{
            height: 40px;
            /*background: #3791DA;*/
            /*color: #fff;*/
            font-size: 18px;
            line-height: 40px;
            /*border-bottom:1px solid #9E9E9E;*/
            display: inline-block;
            padding:0 10px;
            margin: 10px;
            /*border-radius: 10px;*/
            /*border-right: 1px solid;*/
        }
        .content{
            height: 100%;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <p class="locality-p"><img src="/img/commonTheme/theme6/wangluo.png" style="margin-right: 5px"></img>入党积极分子审核</p>
            <button class="layui-btn" id="temp" style="float:right;margin: 10px;">模板下载</button>
        </div>
        <div class="content">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div style="padding: 0px 8px">
                            <table id="demo" lay-filter="test"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/html" id="doSth">
    <a class="layui-btn layui-btn-xs" lay-event="submit" id="submit">提交审批</a>
<%--    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>--%>
<%--    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>--%>
</script>
<script>

    layui.use(['table', 'layer', 'form','laydate'], function () {
        var table = layui.table,
            layer = layui.layer,
            laydate = layui.laydate;

        //自定义格式
        laydate.render({
            elem: '#test11'
            ,format: 'yyyy年MM月dd日'
        });

        //,templet:function(d){       return   }
        table.render({
            elem: '#demo'
            , url:'/partyMember/passParty?phase=2'
            , page:true
            ,type: 'get'
            ,cols: [[
                {field:'runId',title:'流水号',align:'center'}
                ,{field:'userName',title:'姓名',align:'center'}
                ,
                {
                    field: 'sex', title: '性别', align: 'center',templet: function(d){
                        if(d.sex=='0'){
                            return  d.sex = '男'
                        }else{
                            return d.sex = '女'
                        }
                    }}
                , {field: 'parentPedtName', title: '所属部门', align: 'center'}
                , {field: 'applyTime', title: '入党申请时间', align: 'center',templet: function(d){
                        return layui.util.toDateString( d.applyTime , 'yyyy-MM-dd');
                    }}
                , {field: 'activistsTime', title: '确认积极分子时间', align: 'center',templet: function(d){
                        if(d.activistsTime!=undefined&&d.activistsTime!=""){
                            return layui.util.toDateString( d.activistsTime , 'yyyy-MM-dd');
                        }else{
                            return "未确认积极分子"
                        }

                    }}
                ,{title: '操作', align: 'center', toolbar: '#doSth', width: 300,}
            ]]
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.totleNum, //解析数据长度
                    "data": res.obj, //解析数据列表
                };
            }
        });

        table.on('tool(test)', function (obj) {
            var data= obj.data
            if("0"==data.state){
                layer.msg("当前以提交,请等待审核通过!")
                return;
            }
            if(data.nodeStatus =="2"){
                var attr = data.attachmentIdReport;
                var nu = 0;
                if(attr == undefined){

                }else{
                    nu = attr.split(",").length
                }
                layer.confirm('此人提交了'+nu +'份思想报告,确定提交此人到发展对象吗?', {icon: 3, title: '提示'}, function (index) {
                        layer.close(index);
                        $.ajax({
                            type: 'get',
                            url: '/partyMember/activeParty',
                            data: {
                                phase:2,
                                userId:data.userId
                            },
                            success: function (res) {
                                if(res.flag == true){
                                    $.popWindow('/workflow/work/workform?opflag=1&flowId='+res.object.flowId+'&type=new&flowStep=1&prcsId=1&runId='+res.object.runId);
                                }else{
                                    layer.msg(res.msg);
                                }
                            }
                        });
                    },
                    function(index){
                        layer.close(index)
                    }
                )
            }else {
                layer.confirm('确定要提交吗？', {icon: 3, title: '提示'}, function (index) {
                        layer.close(index);
                        $.ajax({
                            type: 'get',
                            url: '/partyMember/activeParty',
                            data: {
                                phase:2,
                                userId:data.userId
                            },
                            success: function (res) {
                                if(res.flag == true){
                                    $.popWindow('/workflow/work/workform?opflag=1&flowId='+res.object.flowId+'&type=new&flowStep=1&prcsId=1&runId='+res.object.runId);
                                }else{
                                    layer.msg(res.msg);
                                }
                            }
                        });
                    },
                    function(index){
                        layer.close(index)
                    }
                )
            }
           //$('#submit').click(function(){

            })
            // if (event == 'submit') {
            //
            // }
        $("#temp").click(function(){
            $.ajax({
                type: 'post',
                url: '/partyMember/getTemp',
                dataType: 'json',
                data:{phase:2},
                success:function(res){
                    var str = '<div class="clear" style="margin-right:20px;margin-left:20px;">\n' +
                        '                        <table border="0" class="speak_document" style="min-width:50px;width:100%;">\n' +
                        '                        </table>\n' +
                        '                        </div>'
                    layer.open({
                        type: 1,
                        title:[''],
                        area: ['560px', '260px'],
                        shadeClose: true, //点击遮罩关闭
                        content: str,
                        success:function(){
                            var d = res.obj;
                            for(var j =0 ;j < d.length ; j++){
                                var attachment = d[j].attachment;
                                $('.speak_document').append(d[j].flowName+"模板下载")
                                if(attachment == ''){
                                    $('.speak_document').append('<div><span style="color:red">模板为空</span></div>')
                                }else{
                                    $('.speak_document').append(attachView(attachment,'','3','0','1','0'));
                                }

                                $('.speak_document').append("<div></div>")

                            }
                            $(document).on('mouseover','.divShow',function () {
                                $(this).find('.operationDiv').show();
                            })
                            $(document).on('mouseout','.divShow',function () {
                                $(this).find('.operationDiv').hide();
                            })
                        },
                        yes:function(index){

                        }
                    })
                }
            })

        })
        })
    function runWorkListPage() {
        location.reload();
    }
   // })

</script>
